package com.zhouyu;

import com.zhouyu.six.*;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test06 {

	public static void main(String[] args) {
//		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring06.xml");

		/**
		 * set 方法赋值
		 */
		/*InjectBean injectBean = (InjectBean) context.getBean("injectBean");
		injectBean.test();*/

		/**
		 * 构造方法赋值 注入
		 */
		/*InjectBeanByConstructor injectBeanByConstructor = (InjectBeanByConstructor) context.getBean("injectBeanByConstructor");
		injectBeanByConstructor.test();*/

		/**
		 * byType 以及byName 注入
		 * Spring在通过byName的自动填充属性时流程是：
		 * 找到所有set方法所对应的XXX部分的名字
		 * 根据XXX部分的名字去获取bean
		 *
		 * Spring在通过byType的自动填充属性时流程是：
		 * 获取到set方法中的唯一参数的参数类型，并且根据该类型去容器中获取bean
		 * 如果找到多个，会报错。
		 */
		/*InjectBeanByType injectBeanByType = (InjectBeanByType) context.getBean("injectBeanByType");
		injectBeanByType.test();*/


		/**
		 * autowire= default情况  默认不会自动注入
		 */
		/*InjectAutowireDefault injectAutowireDefault = (InjectAutowireDefault) context.getBean("injectAutowireDefault");
		injectAutowireDefault.test();*/

		/**
		 * Autowired
		 */
		/*AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
		InjectAutowiredBean injectAutowiredBean = (InjectAutowiredBean) context.getBean("injectAutowiredBean");
		injectAutowiredBean.test();*/

		/**
		 * 泛型 桥接方法
		 */
		/*AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
		BridgeBean bridgeBean = (BridgeBean) context.getBean("bridgeBean");
		bridgeBean.test();*/

		/**
		 * 自动注入的属性不可以设置为static验证
		 */
		/*AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
		StaticBean staticBean = (StaticBean) context.getBean("staticBean");
		staticBean.test();
		StaticBean staticBean1 = (StaticBean) context.getBean("staticBean");
		staticBean.test();
		staticBean1.test();*/


	}
}
